/**
 * Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng)
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package cn.well.cloud.exception.enums;

import cn.stylefeng.roses.kernel.model.exception.AbstractBaseExceptionEnum;

/**
 * 所有业务异常的枚举
 * 4xx 异常
 * 5xx 异常
 * 6xx 异常
 * 2019年12月20日
 * @author wison
 *
 */
public enum BizExceptionEnum implements AbstractBaseExceptionEnum {
    
    AUTH_REQUEST_ERROR(400, "获取用户凭证失败"),

    /**
     * 参数异常
     */
    PARAM_MISS(400, "缺少必要参数,类型:{},参数名:{}"),
    PARAM_ERROR(400, "参数不正确"),
    PARAM_BODY_MISS(400, "请求体不完整"),
    
    /**
     * 数据异常
     */
    DATA_MISS_ERROR(500, "数据异常"),
    
    /**
     * request 请求类型错误
     */
    REQUEST_METHOD_ERROR(400, "请求方式不对,请确认是否为POST"),
    REQUEST_POST_ERROR(400, "POST请求未增加消息头Content-Type:application/json;charset=UTF-8"),
    
    /**
     * token异常
     */
    TOKEN_EXPIRED(501, "token过期"),
    TOKEN_ERROR(500, "token验证失败"),
    TOKEN_PRE_MISS(500, "header中缺少Bearer字段"),
    TOKEN_ASSERTED_MISS(500, "token签名与本地计算的签名不匹配"),
    OPENID(502, "openId为null"),
    

    /**
     * 签名异常
     */
    SIGN_ERROR(500, "签名验证失败"),

    /**
     * 其他
     */
    SERVER_ERROR(400, "未知异常")

;

    BizExceptionEnum(int code, String message) {
        this.code = code;
        this.message = message;
    }

    private Integer code;

    private String message;

    @Override
    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    @Override
    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }
}
